package com.vn.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name="PurchaseContract")
public class PurchaseContract implements Serializable{
	
	public PurchaseContract(){}

	public PurchaseContract(Date dateCreate, Customer customer,
			Compartment compartment, double cost, PaymentMode paymentMode,
			double totalInterest, short statusContract, short statusSale,
			Storage storage, String log) {
		super();
		this.dateCreate = dateCreate;
		this.customer = customer;
		this.compartment = compartment;
		this.cost = cost;
		this.paymentMode = paymentMode;
		this.totalInterest = totalInterest;
		this.statusContract = statusContract;
		this.statusSale = statusSale;
		this.storage = storage;
		this.log = log;
	}

	@Id
	@GeneratedValue
	@Column(name="IDContract")
	private int id;
	
	@Column(name="DateCreate")
	private Date dateCreate;
	
	@JoinColumn(name="CustomerID",referencedColumnName="IdentityCardNo_Cus")
	@ManyToOne
	private Customer customer;
	
	@JoinColumn(name="CompartmentID",referencedColumnName="IDCompartment")
	@ManyToOne
	private Compartment compartment;
	
	@Column(name="Cost")
	private double cost;
	
	@JoinColumn(name="PaymentModeID",referencedColumnName="IDPaymentMode")
	@ManyToOne
	private PaymentMode paymentMode;
	
	@Column(name="TotalInterest")
	private double totalInterest;
	
	@Column(name="StatusContract")
	private short statusContract=0;
	
	@Column(name="StatusSale")
	private short statusSale;
	
	@JoinColumn(name="FolderName",referencedColumnName="FolderName")
	@ManyToOne
	private Storage storage;
	
	@Column(name="Log")
	private String log;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	public Compartment getCompartment() {
		return compartment;
	}

	public void setCompartment(Compartment compartment) {
		this.compartment = compartment;
	}

	public double getCost() {
		return cost;
	}

	public void setCost(double cost) {
		this.cost = cost;
	}

	public PaymentMode getPaymentMode() {
		return paymentMode;
	}

	public void setPaymentMode(PaymentMode paymentMode) {
		this.paymentMode = paymentMode;
	}

	public double getTotalInterest() {
		return totalInterest;
	}

	public void setTotalInterest(double totalInterest) {
		this.totalInterest = totalInterest;
	}

	public short getStatusContract() {
		return statusContract;
	}

	public void setStatusContract(short statusContract) {
		this.statusContract = statusContract;
	}

	public short getStatusSale() {
		return statusSale;
	}

	public void setStatusSale(short statusSale) {
		this.statusSale = statusSale;
	}

	public Storage getStorage() {
		return storage;
	}

	public void setStorage(Storage storage) {
		this.storage = storage;
	}

	public String getLog() {
		return log;
	}

	public void setLog(String log) {
		this.log = log;
	}

	public Date getDateCreate() {
		return dateCreate;
	}

	public void setDateCreate(Date dateCreate) {
		this.dateCreate = dateCreate;
	}
	
	@OneToMany
	private List<PaymentInstallment> paymentInstallments;

	public List<PaymentInstallment> getPaymentInstallments() {
		return paymentInstallments;
	}

	public void setPaymentInstallments(List<PaymentInstallment> paymentInstallments) {
		this.paymentInstallments = paymentInstallments;
	}
	
	@OneToMany
	private List<ChargeRegisterPayment> chargeRegisterPayments;

	public List<ChargeRegisterPayment> getChargeRegisterPayments() {
		return chargeRegisterPayments;
	}

	public void setChargeRegisterPayments(
			List<ChargeRegisterPayment> chargeRegisterPayments) {
		this.chargeRegisterPayments = chargeRegisterPayments;
	}
	
}
